package a.j;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterJob;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class tg
  extends JPanel
{
  private Printable a;
  private PageFormat c;
  private a_ d;
  private PrinterJob e;
  private JScrollPane f;
  private JComboBox g;
  private JPanel h;
  public static final String i = "ZOOM_TO_FIT";
  public static final String j = "ZOOM_TO_FIT_WIDTH";
  public static final String k = "PAGE_FORMAT_ACTION";
  public static final String l = "PRINT_ACTION";
  public static final String m = "ZOOM_IN_ACTION";
  public static final String n = "ZOOM_OUT_ACTION";
  static ResourceBundle o;
  static Class p;
  public static int q;
  
  public tg(PrinterJob paramPrinterJob, Printable paramPrintable, int paramInt1, int paramInt2, PageFormat paramPageFormat)
  {
    super(new BorderLayout());
    this.e = paramPrinterJob;
    paramPrinterJob.setPrintable(paramPrintable, paramPageFormat);
    this.a = paramPrintable;
    this.c = paramPageFormat;
    this.g = new JComboBox(new Object[] { a("ZOOM_TO_FIT"), a("ZOOM_TO_FIT_WIDTH"), "400%", "300%", "200%", "100%", "90%", "80%", "70%", "60%", "50%", "25%", "10%" });
    this.g.setEditable(true);
    this.h = new JPanel(new FlowLayout(3));
    c_ localc_ = new c_();
    a(localc_, "PAGE_FORMAT_ACTION");
    this.h.add(new JButton(localc_));
    b_ localb_ = new b_();
    a(localb_, "PRINT_ACTION");
    this.h.add(new JButton(localb_));
    JPanel localJPanel = new JPanel(new BorderLayout());
    this.d = new a_(0, paramInt1, paramInt2, 500);
    Action localAction1 = this.d.d();
    a(localAction1, "ZOOM_IN_ACTION");
    Action localAction2 = this.d.e();
    a(localAction2, "ZOOM_OUT_ACTION");
    this.h.add(new JButton(localAction1));
    this.h.add(new JButton(localAction2));
    localJPanel.setBorder(BorderFactory.createEtchedBorder());
    localJPanel.add(this.f = new JScrollPane(this.d), "Center");
    this.f.setPreferredSize(new Dimension(400, 700));
    this.d.addPropertyChangeListener("ZOOM", new PropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent paramAnonymousPropertyChangeEvent)
      {
        int i = ((Number)paramAnonymousPropertyChangeEvent.getNewValue()).intValue();
        String str = String.valueOf(i / 10) + "." + String.valueOf(i % 10) + "%";
        tg.this.g.setSelectedItem(str);
      }
    });
    this.g.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        boolean bool2 = ld.E;
        boolean bool1 = ld.D;
        if (!bool2) {
          if (tg.this.g.getSelectedIndex() == 0)
          {
            tg.this.b();
            if (!bool2) {
              if (!bool1) {
                return;
              }
            }
          }
          else
          {
            if (bool2) {
              break label91;
            }
          }
        }
        if (tg.this.g.getSelectedIndex() == 1)
        {
          if (bool2) {
            break label91;
          }
          tg.this.c();
          if (!bool1) {
            return;
          }
        }
        label91:
        String str1 = tg.this.g.getSelectedItem().toString().trim();
        if (!bool2) {
          if (str1.indexOf('%') > 0) {
            str1 = str1.substring(0, str1.indexOf('%')).trim();
          }
        }
        try
        {
          double d = Double.parseDouble(str1);
          tg.this.d.f((int)(d * 10.0D));
        }
        catch (Exception localException)
        {
          int i = tg.this.d.c();
          String str2 = String.valueOf(i / 10) + "." + String.valueOf(i % 10) + "%";
          tg.this.g.setSelectedItem(str2);
        }
      }
    });
    this.d.f(250);
    this.h.add(this.g);
    add(localJPanel, "Center");
    add(this.h, "North");
  }
  
  public PageFormat a()
  {
    return this.c;
  }
  
  public void a(PageFormat paramPageFormat)
  {
    if (!ld.E) {
      if (paramPageFormat == null) {
        throw new NullPointerException();
      }
    }
    if (paramPageFormat != this.c)
    {
      this.c = paramPageFormat;
      this.d.a();
      repaint();
    }
  }
  
  protected String a(String paramString)
  {
    if ((ld.E) || (o != null)) {
      try
      {
        return o.getString(paramString);
      }
      catch (MissingResourceException localMissingResourceException) {}
    }
    return paramString;
  }
  
  public void a(int paramInt1, int paramInt2, int paramInt3)
  {
    this.d.a(paramInt1);
    this.d.b(paramInt2);
    this.d.c(paramInt3);
    this.d.a();
  }
  
  public void b()
  {
    this.d.f(this.d.a(this.f.getViewport().getWidth() - 3, this.f.getViewport().getHeight() - 3));
  }
  
  public void c()
  {
    this.d.f(this.d.d(this.f.getViewport().getWidth() - 20));
  }
  
  public void a(JComponent paramJComponent)
  {
    this.h.add(paramJComponent);
  }
  
  protected void a(Action paramAction, String paramString)
  {
    paramAction.putValue("ActionCommandKey", paramString);
    paramAction.putValue("Name", a(paramString + ".NAME"));
  }
  
  static Class b(String paramString)
  {
    try
    {
      return Class.forName(paramString);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }
  
  static
  {
    try
    {
      o = ResourceBundle.getBundle((p == null ? (tg.p = b("a.j.tg")) : p).getName());
    }
    catch (Exception localException) {}
  }
  
  final class a_
    extends JPanel
    implements Scrollable
  {
    private int a;
    private int b = 1;
    private int c;
    private int d = 10;
    private PageFormat e;
    private double f;
    private int g;
    private double h = 10.0D;
    private double j = 5.0D;
    private double k;
    private boolean l;
    
    a_(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    {
      a(paramInt1);
      c(paramInt3);
      b(paramInt2);
      this.k = (Toolkit.getDefaultToolkit().getScreenResolution() / 72.0D);
      setMinimumSize(new Dimension((int)Math.rint(paramInt2 * 2 * this.h + 5.0D), (int)Math.rint(this.c * 2 * this.h + 5.0D)));
      f(paramInt4);
    }
    
    public void a(int paramInt)
    {
      if (paramInt < 0) {
        throw new IllegalArgumentException("page must be non-negative");
      }
      this.a = paramInt;
    }
    
    public void b(int paramInt)
    {
      boolean bool2 = ld.E;
      boolean bool1 = ld.D;
      if (!bool2)
      {
        if (paramInt <= 0) {
          throw new IllegalArgumentException("columns must be greater 0");
        }
        this.b = paramInt;
      }
      this.c = 1;
      do
      {
        while (!bool1)
        {
          if (this.c * this.b >= this.d) {
            break;
          }
          this.c += 1;
        }
      } while (bool2);
    }
    
    public void c(int paramInt)
    {
      boolean bool2 = ld.E;
      boolean bool1 = ld.D;
      if (!bool2)
      {
        if (paramInt < 0) {
          throw new IllegalArgumentException("pages must be non-negative");
        }
        this.d = paramInt;
      }
      this.c = 1;
      do
      {
        while (!bool1)
        {
          if (this.c * this.b >= this.d) {
            break;
          }
          this.c += 1;
        }
      } while (bool2);
    }
    
    public int d(int paramInt)
    {
      double d1 = (paramInt - this.b * 2 * this.h) / (this.b * tg.this.c.getWidth() * this.k);
      d1 = Math.max(0.05D, d1);
      return (int)Math.rint(Math.floor(d1 * 1000.0D));
    }
    
    public int a(int paramInt1, int paramInt2)
    {
      double d1 = (paramInt1 - this.b * 2 * this.h) / (this.b * tg.this.c.getWidth() * this.k);
      this.f = Math.max(0.05D, this.f);
      double d2 = (paramInt2 - this.c * 2 * this.h) / (this.c * tg.this.c.getHeight() * this.k);
      double d3 = Math.min(d1, d2);
      return (int)Math.rint(Math.floor(d3 * 1000.0D));
    }
    
    public synchronized void f(int paramInt)
    {
      boolean bool = ld.E;
      if (!bool) {
        if (this.l) {
          return;
        }
      }
      if (!bool)
      {
        if (this.g == paramInt) {
          return;
        }
        if (bool) {}
      }
      else if (paramInt < 50)
      {
        paramInt = 50;
      }
      int i = this.g;
      this.g = paramInt;
      this.f = (paramInt / 1000.0D);
      setPreferredSize(new Dimension((int)Math.rint(this.b * (2.0D * this.h + tg.this.c.getWidth() * this.f * this.k)), (int)Math.rint(this.c * (2.0D * this.h + tg.this.c.getHeight() * this.f * this.k))));
      revalidate();
      repaint();
      try
      {
        this.l = true;
        firePropertyChange("ZOOM", i, paramInt);
      }
      finally
      {
        this.l = false;
      }
    }
    
    public void a()
    {
      int i = c();
      this.g = 0;
      f(i);
    }
    
    public int c()
    {
      return this.g;
    }
    
    protected void paintComponent(Graphics paramGraphics)
    {
      boolean bool2 = ld.E;
      boolean bool1 = ld.D;
      super.paintComponent(paramGraphics);
      Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
      Paper localPaper = tg.this.c.getPaper();
      double d1 = localPaper.getWidth();
      double d2 = localPaper.getHeight();
      if (!bool2) {
        if (tg.this.c.getOrientation() != 1)
        {
          double d3 = d1;
          d1 = d2;
          d2 = d3;
        }
      }
      Insets localInsets = super.getInsets();
      double d4 = this.k * this.f;
      Rectangle2D.Double localDouble1 = new Rectangle2D.Double(0.0D, 0.0D, 0.0D, 0.0D);
      double d5 = this.h;
      double d6 = this.h;
      int i = 0;
      label605:
      label617:
      do
      {
        if (i >= (int)Math.ceil(this.d / this.b)) {
          break;
        }
        int m = 0;
        do
        {
          do
          {
            if (m >= this.b) {
              break label802;
            }
            d5 = localInsets.left + this.h + m * (d1 * d4) + m * 2 * this.h;
            d6 = localInsets.top + this.h + i * (d2 * d4) + i * 2 * this.h;
            if (bool1) {
              break;
            }
            if (m + i * this.b >= this.d) {
              break label802;
            }
            localDouble1.width = (d1 * d4);
            localDouble1.height = (d2 * d4);
            localDouble1.x = (d5 + this.j);
            localDouble1.y = (d6 + this.j);
            localGraphics2D.setColor(getBackground().darker());
            localGraphics2D.fill(localDouble1);
            localDouble1.x = d5;
            localDouble1.y = d6;
            localGraphics2D.setColor(Color.white);
            localGraphics2D.fill(localDouble1);
            localGraphics2D.setColor(Color.black);
            localGraphics2D.draw(localDouble1);
            double d7 = localDouble1.x;
            double d8 = localDouble1.y;
            localDouble1.setFrame(tg.this.c.getImageableX() * d4 + d7, tg.this.c.getImageableY() * d4 + d8, tg.this.c.getImageableWidth() * d4, tg.this.c.getImageableHeight() * d4);
            int n = 1;
            try
            {
              AffineTransform localAffineTransform = localGraphics2D.getTransform();
              Shape localShape1 = localGraphics2D.getClip();
              localGraphics2D.translate(d7, d8);
              localGraphics2D.scale(d4, d4);
              Shape localShape2 = localGraphics2D.getClip();
              Rectangle2D.Double localDouble2 = new Rectangle2D.Double(tg.this.c.getImageableX(), tg.this.c.getImageableY(), tg.this.c.getImageableWidth(), tg.this.c.getImageableHeight());
              Rectangle localRectangle = new Rectangle(0, 0, (int)Math.ceil(d1), (int)Math.ceil(d2));
              if (!bool2) {
                if (localShape2.intersects(localRectangle))
                {
                  localGraphics2D.clip(localDouble2);
                  n = tg.this.a.print(localGraphics2D, tg.this.c, this.a + m + this.b * i);
                  if (bool2) {
                    break label617;
                  }
                  if (!bool1) {
                    break label605;
                  }
                }
              }
              n = 0;
              localGraphics2D.setTransform(localAffineTransform);
              localGraphics2D.setClip(localShape1);
            }
            catch (Exception localException)
            {
              n = 1;
              localException.printStackTrace();
            }
            if (n == 1)
            {
              localDouble1.width = (d1 * d4);
              localDouble1.height = (d2 * d4);
              localDouble1.x = d5;
              localDouble1.y = d6;
              localGraphics2D.setColor(Color.lightGray);
              localGraphics2D.fill(localDouble1);
              localGraphics2D.setColor(Color.red);
              Line2D.Double localDouble = new Line2D.Double(localDouble1.x, localDouble1.y, localDouble1.x + localDouble1.width, localDouble1.y + localDouble1.height);
              localGraphics2D.draw(localDouble);
              localDouble.x1 = localDouble.x2;
              localDouble.x2 = localDouble1.x;
              localGraphics2D.draw(localDouble);
              localGraphics2D.setColor(Color.darkGray);
              localGraphics2D.draw(localDouble1);
              if (!bool2) {}
            }
            else
            {
              localGraphics2D.setColor(Color.lightGray);
              localGraphics2D.draw(localDouble1);
            }
            m++;
          } while (!bool1);
          i++;
        } while (bool2);
      } while (!bool1);
      label802:
    }
    
    public Action d()
    {
      return new tg.10(this, "+");
    }
    
    public Action e()
    {
      return new tg.9(this, "-");
    }
    
    public Dimension getPreferredScrollableViewportSize()
    {
      return getPreferredSize();
    }
    
    public int getScrollableBlockIncrement(Rectangle paramRectangle, int paramInt1, int paramInt2)
    {
      return 10;
    }
    
    public boolean getScrollableTracksViewportHeight()
    {
      return false;
    }
    
    public boolean getScrollableTracksViewportWidth()
    {
      return false;
    }
    
    public int getScrollableUnitIncrement(Rectangle paramRectangle, int paramInt1, int paramInt2)
    {
      return 20;
    }
  }
  
  final class b_
    extends AbstractAction
  {
    public b_()
    {
      super();
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      boolean bool2 = ld.E;
      tg.this.e.setPrintable(tg.this.a, tg.this.c);
      tg.a_ locala_ = tg.this.d;
      tg localtg = tg.this;
      JRootPane localJRootPane = SwingUtilities.getRootPane(tg.this.d);
      if (!bool2)
      {
        if (localJRootPane != null) {
          localJRootPane.getGlassPane().setVisible(true);
        }
      }
      else
      {
        if ((bool2) || (localJRootPane.getGlassPane() != null)) {
          if (bool2) {}
        }
        bool1 = localJRootPane.getGlassPane().isVisible();
        if (bool2) {
          return;
        }
        if (!ld.D) {
          break label123;
        }
      }
      boolean bool1 = false;
      label123:
      new tg.3(this, locala_, localtg, bool1, localJRootPane).start();
    }
  }
  
  final class c_
    extends AbstractAction
  {
    public c_()
    {
      super();
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      boolean bool2 = ld.E;
      tg.a_ locala_ = tg.this.d;
      tg localtg = tg.this;
      JRootPane localJRootPane = SwingUtilities.getRootPane(tg.this.d);
      boolean bool1;
      if ((bool2) || (localJRootPane != null))
      {
        if ((bool2) || (localJRootPane.getGlassPane() != null)) {
          if (bool2) {}
        }
        bool1 = localJRootPane.getGlassPane().isVisible();
        localJRootPane.getGlassPane().setVisible(true);
        if (bool2) {
          return;
        }
        if (!ld.D) {}
      }
      else
      {
        bool1 = false;
      }
      new tg.6(this, localtg, bool1, localJRootPane).start();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.j.tg

 * JD-Core Version:    0.7.0.1

 */